/* eslint valid-jsdoc: "off" */

'use strict';
const path = require("path");

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {
  };
  config.security = {
    xframe: {
      enable: false,
    },
    csrf: {
      enable: false,
      // headerName: 'x-csrf-token',// 自定义请求头
    }
  };
  config.cors = {
    origin: '*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS'
  };

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1640574616160_9910';

  // add your middleware config here
  config.middleware = ["response"];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
    upload_path: 'app/public/admin/uploads',
    domainPath: "http://127.0.0.1:7001/admin/uploads"
  };
  config.static = {
    prefix: '/',
    dir: [path.join(appInfo.baseDir, 'app/public')],
    dynamic: true,
    preload: false,
    buffer: false,
    maxFiles: 1000,
  }
  config.sequelize = {
    datasources: [
      {
        dialect: 'mysql',
        host: '127.0.0.1',
        // 端口号
        port: '3306',
        // 用户名
        username: 'test1',
        // username: 'root',

        // 密码
        password: '123456',
        // password: '',
        // 数据库名
        database: 'test1',
        delegate: 'model', // load all models to app.adminModel and ctx.adminModel
        baseDir: 'model', // load models from `app/admin_model/*.js`
      },
      {
        dialect: 'mysql',
        host: '127.0.0.1',
        // 端口号
        port: '3306',
        // 用户名
        username: 'test2',
        // username: 'root',

        // 密码
        password: '123456',
        // password: '',
        // 数据库名
        database: 'test2',
        delegate: 'adminModel', // load all models to app.adminModel and ctx.adminModel
        baseDir: 'admin_model', // load models from `app/admin_model/*.js`
      }
    ],

  }

  config.multipart = {
    // whitelist: ['.png','jpg'], // 覆盖整个白名单，只允许上传 '.png' 格式
  }
  return {
    ...config,
    ...userConfig,
  };
};
